#pragma once
#include<string>
#include<cstdlib>
#include<ctime>
#include"star.h"
#pragma once
using namespace std;

void Character::PrintBackstory()//打印背景故事
{
    cout << this->backstory << endl;
}

Character::Character(int m_id)//构造函数
{
    this->id = m_id;
    this->choose = 0;
    for (int i = 7; i < 10; i++)
    {
        this->dice[i] = 0;
    }
    switch (m_id)
    {
    case 1:
        this->character_name = "投资人";
        this->backstory = "投资人爱风险，要么盆满钵满，要么倾家荡产。";
        this->dice[0] = -8;
        this->dice[1] = -2;
        this->dice[2] = -1;
        this->dice[3] = 1;
        this->dice[4] = 2;
        this->dice[5] = 10;
        break;
    case 2:
        this->character_name = "普通人";
        this->backstory = "普通人只会规规矩矩过一生。";
        this->dice[0] = 1;
        this->dice[1] = 2;
        this->dice[2] = 3;
        this->dice[3] = 4;
        this->dice[4] = 5;
        this->dice[5] = 6;
        break;
    case 3:
        this->character_name = "老狗";
        this->backstory = "有句话叫：稳如老狗。";
        this->dice[0] = 3;
        this->dice[1] = 3;
        this->dice[2] = 3;
        this->dice[3] = 3;
        this->dice[4] = 3;
        this->dice[5] = 3;
        break;
    case 4:
        this->character_name = "双生子";
        this->backstory = "双生子有两个灵魂，可选两种色子。";
        break;
    case 5:
        this->character_name = "上班族！";
        this->backstory = "上班族干的就是比别人多。";
        this->dice[0] = 1;
        this->dice[1] = 3;
        this->dice[2] = 0;
        this->dice[3] = 5;
        this->dice[4] = 2;
        this->dice[5] = 6;
        this->dice[6] = 7;
        break;
    case 6:
        this->character_name = "破败王";
        this->backstory = "破败王会变成别人，拥有他人的技能。";
        break;
    case 7:
        this->character_name = "跳跳蛙";
        this->backstory = "跳跳蛙很能跳。";
        this->dice[0] = 0;
        this->dice[1] = 2;
        this->dice[2] = 2;
        this->dice[3] = 6;
        this->dice[4] = 6;
        this->dice[5] = 0;
        break;
    case 8:
        this->character_name = "差生 ";
        this->backstory = "差生只会走几个小的步数，多的不会走了。";
        this->dice[0] = 2;
        this->dice[1] = 2;
        this->dice[2] = 3;
        this->dice[3] = 3;
        this->dice[4] = 4;
        this->dice[5] = 4;
        break;
    case 9:
        this->character_name = "小精灵";
        this->backstory = "小精灵飞费停停，更多时候是在飞行。";
        this->dice[0] = 0;
        this->dice[1] = 4;
        this->dice[2] = 4;
        this->dice[3] = 4;
        this->dice[4] = 4;
        this->dice[5] = 4;
        break;
    default:
        break;
    }

}
void Character::setdice()//设置双生子和破败王的色子
{
    if (this->id == 4)
    {
        int co;
        cout << "请输入选择的色子:1或0" << endl;
        cin >> co;
        if (co == 1)
        {
            this->dice[0] = 1;
            this->dice[1] = 2;
            this->dice[2] = 3;
            this->dice[3] = 4;
            this->dice[4] = 5;
            this->dice[5] = 6;
        }
        else
        {
            this->dice[0] = -2;
            this->dice[1] = -10;
            this->dice[2] = 1;
            this->dice[3] = 1;
            this->dice[4] = 2;
            this->dice[5] = 3;
        }

    }
    if (this->id == 6)
    {
        cout << "请确定破败王要成为的角色：" << endl
            << "1.投资人：-8，-2，-1，1，2，10" << endl
            << "2.普通人 ：1、2、3、4、5、6" << endl
            << "3.老狗：3、3、3、3、3、3" << endl
            << "4.双生子（两枚骰子）1, 2, 3, 4, 5, 6" << "\t"
            << "- 2,- 10, 1, 2, 3" << endl
            << "5.上班族 1 3 0 5 2 6 7" << endl
            << "7.跳跳蛙 0、0、2、2、6、6" << endl
            << "8.差生 2、2、3、3、4、4" << endl
            << "9.小精灵 0，4，4，4，4，4" << endl;
        int ch;
        cin >> ch;
        switch (ch)
        {
        case 1://投资人
            this->dice[0] = -8;
            this->dice[1] = -2;
            this->dice[2] = -1;
            this->dice[3] = 1;
            this->dice[4] = 2;
            this->dice[5] = 10;
            break;
        case 2://普通人
            this->dice[0] = 1;
            this->dice[1] = 2;
            this->dice[2] = 3;
            this->dice[3] = 4;
            this->dice[4] = 5;
            this->dice[5] = 6;
            break;
        case 3://老狗
            this->dice[0] = 3;
            this->dice[1] = 3;
            this->dice[2] = 3;
            this->dice[3] = 3;
            this->dice[4] = 3;
            this->dice[5] = 3;
            break;
        case 4://双生子
        {
            int co;
            cout << "请输入选择的色子:1或0" << endl;
            cin >> co;
            if (co == 1)
            {
                this->dice[0] = 1;
                this->dice[1] = 2;
                this->dice[2] = 3;
                this->dice[3] = 4;
                this->dice[4] = 5;
                this->dice[5] = 6;
            }
            else
            {
                this->dice[0] = -2;
                this->dice[1] = -10;
                this->dice[2] = 1;
                this->dice[3] = 1;
                this->dice[4] = 2;
                this->dice[5] = 3;
            }
        }

        break;
        case 5://上班族
            this->dice[0] = 1;
            this->dice[1] = 3;
            this->dice[2] = 8;
            this->dice[3] = 5;
            this->dice[4] = 2;
            this->dice[5] = 6;
            this->dice[6] = 7;
        case 7://跳跳蛙
            this->dice[0] = 0;
            this->dice[1] = 2;
            this->dice[2] = 2;
            this->dice[3] = 6;
            this->dice[4] = 6;
            this->dice[5] = 0;
            break;
        case 8://差生
            this->dice[0] = 0;
            this->dice[1] = 2;
            this->dice[2] = 2;
            this->dice[3] = 6;
            this->dice[4] = 6;
            this->dice[5] = 0;
            break;

        case 9://小精灵
            this->dice[0] = 2;
            this->dice[1] = 2;
            this->dice[2] = 3;
            this->dice[3] = 3;
            this->dice[4] = 4;
            this->dice[5] = 4;
            break;
        default:
            break;
        }
    }
}
int Character::Roll()//摇色子
{

    this->setdice();
    int Ri;
    srand((unsigned)time(NULL));
    if (this->id != 5)
        Ri = rand() % 6;
    else
        Ri = rand() % 7;
    return this->dice[Ri];

}
extern Character** chara = new Character * [20];
extern Map** mp = new Map * [88];
extern Event** event_queue = new Event * [20];
extern Player player[4] = {{1,"A",2,0,0,NULL,NULL} ,{2,"B",2,0,0,NULL,NULL}, {3,"C",2,0,0,NULL,NULL} ,{4,"D",2,0,0,NULL,NULL} };